import { ECSComponentSet } from "./component/ECSComponentSet";
import { ECSEntitySet } from "./entity/ECSEntitySet";
import { ECSEventSet } from "./event/ECSEventSet";
import { ECSSystemSet } from "./system/ECSSystemSet";
import { ECSWorldImpl } from "./ECSWorldImpl";

export * from "./component/ECSComponent";
export * from "./entity/ECSEntity";
export * from "./event/ECSEvent";
export * from "./event/ECSEventSet";
export * from "./system/ECSSystem";

export type Constructor<T = unknown> = new (...args: any[]) => T;

export function ecsclass(name: string) {
    return (ctor: Function) => {
        Object.defineProperty(ctor, "name", {
            value: name,
            writable: false,
        });
    };
}

export interface ECSWorld {

    // 实体集合
    readonly entities: ECSEntitySet;

    // 组件集合
    readonly components: ECSComponentSet;

    // 系统集合
    readonly systems: ECSSystemSet;

    // 事件集合
    readonly events: ECSEventSet;

    start(): void;

    stop(): void;

    update(dt: number): void;

}

export function createECS(): ECSWorld {
    return new ECSWorldImpl();
}
